home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / Pascal / Applications / P4⁄Mac 2.0d4 / Mac source 2.0 / NewOldFile.p < prev    next >
Encoding:
Text File  |  1996-09-28  |  1.5 KB  |  70 lines  |  [TEXT/PJMM]

  1. {Compatibility with Think's NewFileName/OldFileName and related calls.}
  2.  
  3. unit NewOldFile;
  4.  
  5. interface
  6.     uses
  7. {$IFC UNDEFINED THINK_PASCAL}
  8.         Types, QuickDraw, Windows, Dialogs, ToolUtils, Events, Controls, {}
  9.         Memory, Sound, OSUtils, MixedMode, 
  10. {$ENDC}
  11.         Messages, Console;
  12.  
  13.     function GetOutFile (prompt, default: Str255): Str255;
  14.     function GetInFile: Str255;
  15. {$IFC UNDEFINED THINK_PASCAL}
  16.     function NewFileName (prompt: Str255): Str255;
  17.     function OldFileName (prompt: Str255): Str255;
  18. {$ENDC}
  19.  
  20. implementation
  21.  
  22. {NewFileName doesn't work with CodeWarrior!}
  23. {Copied from pascalcompiler.p!}
  24.     function GetOutFile (prompt, default: Str255): Str255;
  25.         var
  26.             reply: SFReply;
  27.     begin
  28.         SFPutFile(Point(-1), prompt, default, nil, reply);
  29.         if reply.good then
  30.             begin
  31.                 if SetVol(nil, reply.vRefNum) <> noErr then
  32.                     ; {We ignore errors for now}
  33.                 GetOutFile := reply.fName;
  34.             end
  35.         else
  36.             GetOutFile := '';
  37.     end; {GetOutFile}
  38.  
  39. {$IFC UNDEFINED THINK_PASCAL}
  40.     function NewFileName (prompt: Str255): Str255;
  41.     begin
  42.         NewFileName := GetOutFile(prompt, '');
  43.     end;
  44.  
  45.     function OldFileName (prompt: Str255): Str255;
  46.         var
  47.             reply: SFReply;
  48.             typeList: SFTypeList;
  49.     begin
  50.         typeList[0] := 'TEXT';
  51.         SFGetFile(Point(-1), prompt, nil, 1, @typeList, nil, reply);
  52.         if reply.good then
  53.             begin
  54.                 if SetVol(nil, reply.vRefNum) <> noErr then
  55.                     ; {We ignore errors for now}
  56.                 OldFileName := reply.fName;
  57.             end
  58.         else
  59.             OldFileName := '';
  60.     end; {OldFileName}
  61. {$ENDC}
  62.  
  63.     function GetInFile: Str255;
  64.         var
  65.             message, count: Integer;
  66.     begin
  67.         GetInFile := OldFileName('');
  68.     end; {GetInFile}
  69.  
  70. end.